// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.gameStates;

import java.io.File;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Stack;
import org.joml.Vector2f;
import se.krka.kahlua.vm.KahluaTable;
import se.krka.kahlua.vm.KahluaTableIterator;
import zombie.Lua.LuaManager;
import zombie.ai.astar.Mover;
import zombie.characters.IsoGameCharacter;
import zombie.characters.IsoPlayer;
import zombie.chat.ChatElement;
import zombie.config.BooleanConfigOption;
import zombie.config.ConfigFile;
import zombie.config.ConfigOption;
import zombie.core.BoxedStaticValues;
import zombie.core.Core;
import zombie.core.SpriteRenderer;
import zombie.core.math.PZMath;
import zombie.core.properties.PropertyContainer;
import zombie.core.utils.BooleanGrid;
import zombie.debug.DebugLog;
import zombie.debug.DebugOptions;
import zombie.debug.LineDrawer;
import zombie.erosion.ErosionData;
import zombie.input.GameKeyboard;
import zombie.input.Mouse;
import zombie.iso.BuildingDef;
import zombie.iso.IsoCamera;
import zombie.iso.IsoCell;
import zombie.iso.IsoChunk;
import zombie.iso.IsoChunkMap;
import zombie.iso.IsoDirections;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoLightSource;
import zombie.iso.IsoMetaGrid;
import zombie.iso.IsoObject;
import zombie.iso.IsoObjectPicker;
import zombie.iso.IsoRoomLight;
import zombie.iso.IsoUtils;
import zombie.iso.IsoWorld;
import zombie.iso.LosUtil;
import zombie.iso.NearestWalls;
import zombie.iso.ParticlesFire;
import zombie.iso.SpriteDetails.IsoFlagType;
import zombie.iso.SpriteDetails.IsoObjectType;
import zombie.iso.areas.IsoBuilding;
import zombie.iso.sprite.IsoSprite;
import zombie.network.GameClient;
import zombie.randomizedWorld.randomizedVehicleStory.RandomizedVehicleStoryBase;
import zombie.randomizedWorld.randomizedVehicleStory.VehicleStorySpawner;
import zombie.ui.TextDrawObject;
import zombie.ui.TextManager;
import zombie.ui.UIElement;
import zombie.ui.UIFont;
import zombie.ui.UIManager;
import zombie.util.Type;
import zombie.vehicles.ClipperOffset;
import zombie.vehicles.EditVehicleState;
import zombie.vehicles.PolygonalMap2;

public final class DebugChunkState extends GameState {
    public static DebugChunkState instance;
    private EditVehicleState.LuaEnvironment m_luaEnv;
    private boolean bExit = false;
    private final ArrayList<UIElement> m_gameUI = new ArrayList();
    private final ArrayList<UIElement> m_selfUI = new ArrayList();
    private boolean m_bSuspendUI;
    private KahluaTable m_table = null;
    private int m_playerIndex = 0;
    private int m_z = 0;
    private int gridX = -1;
    private int gridY = -1;
    private UIFont FONT = UIFont.DebugConsole;
    private String m_vehicleStory = "Basic Car Crash";
    static boolean keyQpressed = false;
    private static ClipperOffset m_clipperOffset = null;
    private static ByteBuffer m_clipperBuffer;
    private static final int VERSION = 1;
    private final ArrayList<ConfigOption> options = new ArrayList();
    private DebugChunkState.BooleanDebugOption BuildingRect = new DebugChunkState.BooleanDebugOption("BuildingRect", true);
    private DebugChunkState.BooleanDebugOption ChunkGrid = new DebugChunkState.BooleanDebugOption("ChunkGrid", true);
    private DebugChunkState.BooleanDebugOption ClosestRoomSquare = new DebugChunkState.BooleanDebugOption("ClosestRoomSquare", true);
    private DebugChunkState.BooleanDebugOption EmptySquares = new DebugChunkState.BooleanDebugOption("EmptySquares", true);
    private DebugChunkState.BooleanDebugOption FlyBuzzEmitters = new DebugChunkState.BooleanDebugOption("FlyBuzzEmitters", true);
    private DebugChunkState.BooleanDebugOption LightSquares = new DebugChunkState.BooleanDebugOption("LightSquares", true);
    private DebugChunkState.BooleanDebugOption LineClearCollide = new DebugChunkState.BooleanDebugOption("LineClearCollide", true);
    private DebugChunkState.BooleanDebugOption NearestWallsOpt = new DebugChunkState.BooleanDebugOption("NearestWalls", true);
    private DebugChunkState.BooleanDebugOption ObjectPicker = new DebugChunkState.BooleanDebugOption("ObjectPicker", true);
    private DebugChunkState.BooleanDebugOption RoomLightRects = new DebugChunkState.BooleanDebugOption("RoomLightRects", true);
    private DebugChunkState.BooleanDebugOption VehicleStory = new DebugChunkState.BooleanDebugOption("VehicleStory", true);
    private DebugChunkState.BooleanDebugOption RandomSquareInZone = new DebugChunkState.BooleanDebugOption("RandomSquareInZone", true);
    private DebugChunkState.BooleanDebugOption ZoneRect = new DebugChunkState.BooleanDebugOption("ZoneRect", true);

    public DebugChunkState() {
        instance = this;
    }

    @Override
    public void enter() {
        instance = this;
        this.load();
        if (this.m_luaEnv == null) {
            this.m_luaEnv = new EditVehicleState.LuaEnvironment(LuaManager.platform, LuaManager.converterManager, LuaManager.env);
        }

        this.saveGameUI();
        if (this.m_selfUI.size() == 0) {
            IsoPlayer isoPlayer = IsoPlayer.players[this.m_playerIndex];
            this.m_z = isoPlayer == null ? 0 : (int)isoPlayer.z;
            this.m_luaEnv.caller.pcall(this.m_luaEnv.thread, this.m_luaEnv.env.rawget("DebugChunkState_InitUI"), this);
            if (this.m_table != null && this.m_table.getMetatable() != null) {
                this.m_table.getMetatable().rawset("_LUA_RELOADED_CHECK", Boolean.FALSE);
            }
        } else {
            UIManager.UI.addAll(this.m_selfUI);
            this.m_luaEnv.caller.pcall(this.m_luaEnv.thread, this.m_table.rawget("showUI"), this.m_table);
        }

        this.bExit = false;
    }

    @Override
    public void yield() {
        this.restoreGameUI();
    }

    @Override
    public void reenter() {
        this.saveGameUI();
    }

    @Override
    public void exit() {
        this.save();
        this.restoreGameUI();

        for (int _int = 0; _int < IsoCamera.cameras.length; _int++) {
            IsoCamera.cameras[_int].DeferedX = IsoCamera.cameras[_int].DeferedY = 0.0F;
        }
    }

    @Override
    public void render() {
        IsoPlayer.setInstance(IsoPlayer.players[this.m_playerIndex]);
        IsoCamera.CamCharacter = IsoPlayer.players[this.m_playerIndex];
        boolean _boolean = true;

        for (int int0 = 0; int0 < IsoPlayer.numPlayers; int0++) {
            if (int0 != this.m_playerIndex && IsoPlayer.players[int0] != null) {
                Core.getInstance().StartFrame(int0, _boolean);
                Core.getInstance().EndFrame(int0);
                _boolean = false;
            }
        }

        Core.getInstance().StartFrame(this.m_playerIndex, _boolean);
        this.renderScene();
        Core.getInstance().EndFrame(this.m_playerIndex);
        Core.getInstance().RenderOffScreenBuffer();

        for (int int1 = 0; int1 < IsoPlayer.numPlayers; int1++) {
            TextDrawObject.NoRender(int1);
            ChatElement.NoRender(int1);
        }

        if (Core.getInstance().StartFrameUI()) {
            this.renderUI();
        }

        Core.getInstance().EndFrameUI();
    }

    @Override
    public GameStateMachine.StateAction update() {
        return !this.bExit && !GameKeyboard.isKeyPressed(60) ? this.updateScene() : GameStateMachine.StateAction.Continue;
    }

    public static DebugChunkState checkInstance() {
        instance = null;
        if (instance != null) {
            if (instance.m_table != null && instance.m_table.getMetatable() != null) {
                if (instance.m_table.getMetatable().rawget("_LUA_RELOADED_CHECK") == null) {
                    instance = null;
                }
            } else {
                instance = null;
            }
        }

        return instance == null ? new DebugChunkState() : instance;
    }

    public void renderScene() {
        IsoCamera.frameState.set(this.m_playerIndex);
        SpriteRenderer.instance.doCoreIntParam(0, IsoCamera.CamCharacter.x);
        SpriteRenderer.instance.doCoreIntParam(1, IsoCamera.CamCharacter.y);
        SpriteRenderer.instance.doCoreIntParam(2, IsoCamera.CamCharacter.z);
        IsoSprite.globalOffsetX = -1.0F;
        IsoWorld.instance.CurrentCell.render();
        if (this.ChunkGrid.getValue()) {
            this.drawGrid();
        }

        this.drawCursor();
        if (this.LightSquares.getValue()) {
            Stack stack = IsoWorld.instance.getCell().getLamppostPositions();

            for (int int0 = 0; int0 < stack.size(); int0++) {
                IsoLightSource isoLightSource = (IsoLightSource)stack.get(int0);
                if (isoLightSource.z == this.m_z) {
                    this.paintSquare(isoLightSource.x, isoLightSource.y, isoLightSource.z, 1.0F, 1.0F, 0.0F, 0.5F);
                }
            }
        }

        if (this.ZoneRect.getValue()) {
            this.drawZones();
        }

        if (this.BuildingRect.getValue()) {
            IsoGridSquare isoGridSquare0 = IsoWorld.instance.getCell().getGridSquare(this.gridX, this.gridY, this.m_z);
            if (isoGridSquare0 != null && isoGridSquare0.getBuilding() != null) {
                BuildingDef buildingDef0 = isoGridSquare0.getBuilding().getDef();
                this.DrawIsoLine(
                    (float)buildingDef0.getX(), (float)buildingDef0.getY(), (float)buildingDef0.getX2(), (float)buildingDef0.getY(), 1.0F, 1.0F, 1.0F, 1.0F, 2
                );
                this.DrawIsoLine(
                    (float)buildingDef0.getX2(),
                    (float)buildingDef0.getY(),
                    (float)buildingDef0.getX2(),
                    (float)buildingDef0.getY2(),
                    1.0F,
                    1.0F,
                    1.0F,
                    1.0F,
                    2
                );
                this.DrawIsoLine(
                    (float)buildingDef0.getX2(),
                    (float)buildingDef0.getY2(),
                    (float)buildingDef0.getX(),
                    (float)buildingDef0.getY2(),
                    1.0F,
                    1.0F,
                    1.0F,
                    1.0F,
                    2
                );
                this.DrawIsoLine(
                    (float)buildingDef0.getX(), (float)buildingDef0.getY2(), (float)buildingDef0.getX(), (float)buildingDef0.getY(), 1.0F, 1.0F, 1.0F, 1.0F, 2
                );
            }
        }

        if (this.RoomLightRects.getValue()) {
            ArrayList arrayList = IsoWorld.instance.CurrentCell.roomLights;

            for (int int1 = 0; int1 < arrayList.size(); int1++) {
                IsoRoomLight isoRoomLight = (IsoRoomLight)arrayList.get(int1);
                if (isoRoomLight.z == this.m_z) {
                    this.DrawIsoRect(
                        (float)isoRoomLight.x, (float)isoRoomLight.y, (float)isoRoomLight.width, (float)isoRoomLight.height, 0.0F, 1.0F, 1.0F, 1.0F, 1
                    );
                }
            }
        }

        if (this.FlyBuzzEmitters.getValue()) {
            zombie.FliesSound.instance.render();
        }

        if (this.ClosestRoomSquare.getValue()) {
            float float0 = IsoPlayer.players[this.m_playerIndex].getX();
            float float1 = IsoPlayer.players[this.m_playerIndex].getY();
            Vector2f vector2f = new Vector2f();
            BuildingDef buildingDef1 = ((zombie.AmbientStreamManager)zombie.AmbientStreamManager.getInstance()).getNearestBuilding(float0, float1, vector2f);
            if (buildingDef1 != null) {
                this.DrawIsoLine(float0, float1, vector2f.x, vector2f.y, 1.0F, 1.0F, 1.0F, 1.0F, 1);
            }
        }

        if (this.m_table != null && this.m_table.rawget("selectedSquare") != null) {
            IsoGridSquare isoGridSquare1 = Type.tryCastTo(this.m_table.rawget("selectedSquare"), IsoGridSquare.class);
            if (isoGridSquare1 != null) {
                this.DrawIsoRect((float)isoGridSquare1.x, (float)isoGridSquare1.y, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, 2);
            }
        }

        LineDrawer.render();
        LineDrawer.clear();
    }

    private void renderUI() {
        int int0 = this.m_playerIndex;
        Stack stack = IsoWorld.instance.getCell().getLamppostPositions();
        int int1 = 0;

        for (int int2 = 0; int2 < stack.size(); int2++) {
            IsoLightSource isoLightSource = (IsoLightSource)stack.get(int2);
            if (isoLightSource.bActive) {
                int1++;
            }
        }

        UIManager.render();
    }

    public void setTable(KahluaTable kahluaTable) {
        this.m_table = kahluaTable;
    }

    public GameStateMachine.StateAction updateScene() {
        IsoPlayer.setInstance(IsoPlayer.players[this.m_playerIndex]);
        IsoCamera.CamCharacter = IsoPlayer.players[this.m_playerIndex];
        UIManager.setPicked(IsoObjectPicker.Instance.ContextPick(Mouse.getXA(), Mouse.getYA()));
        IsoObject isoObject = UIManager.getPicked() == null ? null : UIManager.getPicked().tile;
        UIManager.setLastPicked(isoObject);
        if (GameKeyboard.isKeyDown(16)) {
            if (!keyQpressed) {
                IsoGridSquare isoGridSquare = IsoWorld.instance.getCell().getGridSquare(this.gridX, this.gridY, 0);
                if (isoGridSquare != null) {
                    GameClient.instance.worldObjectsSyncReq.putRequestSyncIsoChunk(isoGridSquare.chunk);
                    DebugLog.General.debugln("Requesting sync IsoChunk %s", isoGridSquare.chunk);
                }

                keyQpressed = true;
            }
        } else {
            keyQpressed = false;
        }

        if (GameKeyboard.isKeyDown(19)) {
            if (!keyQpressed) {
                DebugOptions.instance.Terrain.RenderTiles.NewRender.setValue(true);
                keyQpressed = true;
                DebugLog.General.debugln("IsoCell.newRender = %s", DebugOptions.instance.Terrain.RenderTiles.NewRender.getValue());
            }
        } else {
            keyQpressed = false;
        }

        if (GameKeyboard.isKeyDown(20)) {
            if (!keyQpressed) {
                DebugOptions.instance.Terrain.RenderTiles.NewRender.setValue(false);
                keyQpressed = true;
                DebugLog.General.debugln("IsoCell.newRender = %s", DebugOptions.instance.Terrain.RenderTiles.NewRender.getValue());
            }
        } else {
            keyQpressed = false;
        }

        if (GameKeyboard.isKeyDown(31)) {
            if (!keyQpressed) {
                ParticlesFire.getInstance().reloadShader();
                keyQpressed = true;
                DebugLog.General.debugln("ParticlesFire.reloadShader");
            }
        } else {
            keyQpressed = false;
        }

        IsoCamera.update();
        this.updateCursor();
        return GameStateMachine.StateAction.Remain;
    }

    private void saveGameUI() {
        this.m_gameUI.clear();
        this.m_gameUI.addAll(UIManager.UI);
        UIManager.UI.clear();
        this.m_bSuspendUI = UIManager.bSuspend;
        UIManager.bSuspend = false;
        UIManager.setShowPausedMessage(false);
        UIManager.defaultthread = this.m_luaEnv.thread;
    }

    private void restoreGameUI() {
        this.m_selfUI.clear();
        this.m_selfUI.addAll(UIManager.UI);
        UIManager.UI.clear();
        UIManager.UI.addAll(this.m_gameUI);
        UIManager.bSuspend = this.m_bSuspendUI;
        UIManager.setShowPausedMessage(true);
        UIManager.defaultthread = LuaManager.thread;
    }

    public Object fromLua0(String func) {
        switch (func) {
            case "exit":
                this.bExit = true;
                return null;
            case "getCameraDragX":
                return BoxedStaticValues.toDouble((double)(-IsoCamera.cameras[this.m_playerIndex].DeferedX));
            case "getCameraDragY":
                return BoxedStaticValues.toDouble((double)(-IsoCamera.cameras[this.m_playerIndex].DeferedY));
            case "getPlayerIndex":
                return BoxedStaticValues.toDouble((double)this.m_playerIndex);
            case "getVehicleStory":
                return this.m_vehicleStory;
            case "getZ":
                return BoxedStaticValues.toDouble((double)this.m_z);
            default:
                throw new IllegalArgumentException(String.format("unhandled \"%s\"", func));
        }
    }

    public Object fromLua1(String func, Object arg0) {
        switch (func) {
            case "getCameraDragX":
                return BoxedStaticValues.toDouble((double)(-IsoCamera.cameras[this.m_playerIndex].DeferedX));
            case "getCameraDragY":
                return BoxedStaticValues.toDouble((double)(-IsoCamera.cameras[this.m_playerIndex].DeferedY));
            case "setPlayerIndex":
                this.m_playerIndex = PZMath.clamp(((Double)arg0).intValue(), 0, 3);
                return null;
            case "setVehicleStory":
                this.m_vehicleStory = (String)arg0;
                return null;
            case "setZ":
                this.m_z = PZMath.clamp(((Double)arg0).intValue(), 0, 7);
                return null;
            default:
                throw new IllegalArgumentException(String.format("unhandled \"%s\" \"%s\"", func, arg0));
        }
    }

    public Object fromLua2(String func, Object arg0, Object arg1) {
        byte _byte = -1;
        switch (func.hashCode()) {
            case -1879300743:
                if (func.equals("dragCamera")) {
                    _byte = 0;
                }
            default:
                switch (_byte) {
                    case 0:
                        float float0 = ((Double)arg0).floatValue();
                        float float1 = ((Double)arg1).floatValue();
                        IsoCamera.cameras[this.m_playerIndex].DeferedX = -float0;
                        IsoCamera.cameras[this.m_playerIndex].DeferedY = -float1;
                        return null;
                    default:
                        throw new IllegalArgumentException(String.format("unhandled \"%s\" \"%s\" \\\"%s\\\"", func, arg0, arg1));
                }
        }
    }

    private void updateCursor() {
        int int0 = this.m_playerIndex;
        int int1 = Core.TileScale;
        float float0 = (float)Mouse.getXA();
        float float1 = (float)Mouse.getYA();
        float0 -= (float)IsoCamera.getScreenLeft(int0);
        float1 -= (float)IsoCamera.getScreenTop(int0);
        float0 *= Core.getInstance().getZoom(int0);
        float1 *= Core.getInstance().getZoom(int0);
        int int2 = this.m_z;
        this.gridX = (int)IsoUtils.XToIso(float0, float1, (float)int2);
        this.gridY = (int)IsoUtils.YToIso(float0, float1, (float)int2);
    }

    private void DrawIsoLine(float float2, float float3, float float6, float float7, float float9, float float10, float float11, float float12, int _int) {
        float float0 = (float)this.m_z;
        float float1 = IsoUtils.XToScreenExact(float2, float3, float0, 0);
        float float4 = IsoUtils.YToScreenExact(float2, float3, float0, 0);
        float float5 = IsoUtils.XToScreenExact(float6, float7, float0, 0);
        float float8 = IsoUtils.YToScreenExact(float6, float7, float0, 0);
        LineDrawer.drawLine(float1, float4, float5, float8, float9, float10, float11, float12, _int);
    }

    private void DrawIsoRect(float float0, float float1, float float6, float float7, float float2, float float3, float float4, float float5, int _int) {
        this.DrawIsoLine(float0, float1, float0 + float6, float1, float2, float3, float4, float5, _int);
        this.DrawIsoLine(float0 + float6, float1, float0 + float6, float1 + float7, float2, float3, float4, float5, _int);
        this.DrawIsoLine(float0 + float6, float1 + float7, float0, float1 + float7, float2, float3, float4, float5, _int);
        this.DrawIsoLine(float0, float1 + float7, float0, float1, float2, float3, float4, float5, _int);
    }

    private void drawGrid() {
        int int0 = this.m_playerIndex;
        float float0 = IsoUtils.XToIso(-128.0F, -256.0F, 0.0F);
        float float1 = IsoUtils.YToIso((float)(Core.getInstance().getOffscreenWidth(int0) + 128), -256.0F, 0.0F);
        float float2 = IsoUtils.XToIso(
            (float)(Core.getInstance().getOffscreenWidth(int0) + 128), (float)(Core.getInstance().getOffscreenHeight(int0) + 256), 6.0F
        );
        float float3 = IsoUtils.YToIso(-128.0F, (float)(Core.getInstance().getOffscreenHeight(int0) + 256), 6.0F);
        int int1 = (int)float1;
        int int2 = (int)float3;
        int int3 = (int)float0;
        int int4 = (int)float2;
        int3 -= 2;
        int1 -= 2;

        for (int int5 = int1; int5 <= int2; int5++) {
            if (int5 % 10 == 0) {
                this.DrawIsoLine((float)int3, (float)int5, (float)int4, (float)int5, 1.0F, 1.0F, 1.0F, 0.5F, 1);
            }
        }

        for (int int6 = int3; int6 <= int4; int6++) {
            if (int6 % 10 == 0) {
                this.DrawIsoLine((float)int6, (float)int1, (float)int6, (float)int2, 1.0F, 1.0F, 1.0F, 0.5F, 1);
            }
        }

        for (int int7 = int1; int7 <= int2; int7++) {
            if (int7 % 300 == 0) {
                this.DrawIsoLine((float)int3, (float)int7, (float)int4, (float)int7, 0.0F, 1.0F, 0.0F, 0.5F, 1);
            }
        }

        for (int int8 = int3; int8 <= int4; int8++) {
            if (int8 % 300 == 0) {
                this.DrawIsoLine((float)int8, (float)int1, (float)int8, (float)int2, 0.0F, 1.0F, 0.0F, 0.5F, 1);
            }
        }

        if (GameClient.bClient) {
            for (int int9 = int1; int9 <= int2; int9++) {
                if (int9 % 50 == 0) {
                    this.DrawIsoLine((float)int3, (float)int9, (float)int4, (float)int9, 1.0F, 0.0F, 0.0F, 0.5F, 1);
                }
            }

            for (int int10 = int3; int10 <= int4; int10++) {
                if (int10 % 50 == 0) {
                    this.DrawIsoLine((float)int10, (float)int1, (float)int10, (float)int2, 1.0F, 0.0F, 0.0F, 0.5F, 1);
                }
            }
        }
    }

    private void drawCursor() {
        int int0 = this.m_playerIndex;
        int int1 = Core.TileScale;
        float _float = (float)this.m_z;
        int int2 = (int)IsoUtils.XToScreenExact((float)this.gridX, (float)(this.gridY + 1), _float, 0);
        int int3 = (int)IsoUtils.YToScreenExact((float)this.gridX, (float)(this.gridY + 1), _float, 0);
        SpriteRenderer.instance
            .renderPoly(
                (float)int2,
                (float)int3,
                (float)(int2 + 32 * int1),
                (float)(int3 - 16 * int1),
                (float)(int2 + 64 * int1),
                (float)int3,
                (float)(int2 + 32 * int1),
                (float)(int3 + 16 * int1),
                0.0F,
                0.0F,
                1.0F,
                0.5F
            );
        IsoChunkMap isoChunkMap = IsoWorld.instance.getCell().ChunkMap[int0];

        for (int int4 = isoChunkMap.getWorldYMinTiles(); int4 < isoChunkMap.getWorldYMaxTiles(); int4++) {
            for (int int5 = isoChunkMap.getWorldXMinTiles(); int5 < isoChunkMap.getWorldXMaxTiles(); int5++) {
                IsoGridSquare isoGridSquare0 = IsoWorld.instance.getCell().getGridSquare((double)int5, (double)int4, (double)_float);
                if (isoGridSquare0 != null) {
                    if (isoGridSquare0 != isoChunkMap.getGridSquare(int5, int4, (int)_float)) {
                        int2 = (int)IsoUtils.XToScreenExact((float)int5, (float)(int4 + 1), _float, 0);
                        int3 = (int)IsoUtils.YToScreenExact((float)int5, (float)(int4 + 1), _float, 0);
                        SpriteRenderer.instance
                            .renderPoly(
                                (float)int2,
                                (float)int3,
                                (float)(int2 + 32),
                                (float)(int3 - 16),
                                (float)(int2 + 64),
                                (float)int3,
                                (float)(int2 + 32),
                                (float)(int3 + 16),
                                1.0F,
                                0.0F,
                                0.0F,
                                0.8F
                            );
                    }

                    if (isoGridSquare0 == null
                        || isoGridSquare0.getX() != int5
                        || isoGridSquare0.getY() != int4
                        || (float)isoGridSquare0.getZ() != _float
                        || isoGridSquare0.e != null && isoGridSquare0.e.w != null && isoGridSquare0.e.w != isoGridSquare0
                        || isoGridSquare0.w != null && isoGridSquare0.w.e != null && isoGridSquare0.w.e != isoGridSquare0
                        || isoGridSquare0.n != null && isoGridSquare0.n.s != null && isoGridSquare0.n.s != isoGridSquare0
                        || isoGridSquare0.s != null && isoGridSquare0.s.n != null && isoGridSquare0.s.n != isoGridSquare0
                        || isoGridSquare0.nw != null && isoGridSquare0.nw.se != null && isoGridSquare0.nw.se != isoGridSquare0
                        || isoGridSquare0.se != null && isoGridSquare0.se.nw != null && isoGridSquare0.se.nw != isoGridSquare0) {
                        int2 = (int)IsoUtils.XToScreenExact((float)int5, (float)(int4 + 1), _float, 0);
                        int3 = (int)IsoUtils.YToScreenExact((float)int5, (float)(int4 + 1), _float, 0);
                        SpriteRenderer.instance
                            .renderPoly(
                                (float)int2,
                                (float)int3,
                                (float)(int2 + 32),
                                (float)(int3 - 16),
                                (float)(int2 + 64),
                                (float)int3,
                                (float)(int2 + 32),
                                (float)(int3 + 16),
                                1.0F,
                                0.0F,
                                0.0F,
                                0.5F
                            );
                    }

                    if (isoGridSquare0 != null) {
                        IsoGridSquare isoGridSquare1 = isoGridSquare0.testPathFindAdjacent(null, -1, 0, 0) ? null : isoGridSquare0.nav[IsoDirections.W.index()];
                        IsoGridSquare isoGridSquare2 = isoGridSquare0.testPathFindAdjacent(null, 0, -1, 0) ? null : isoGridSquare0.nav[IsoDirections.N.index()];
                        IsoGridSquare isoGridSquare3 = isoGridSquare0.testPathFindAdjacent(null, 1, 0, 0) ? null : isoGridSquare0.nav[IsoDirections.E.index()];
                        IsoGridSquare isoGridSquare4 = isoGridSquare0.testPathFindAdjacent(null, 0, 1, 0) ? null : isoGridSquare0.nav[IsoDirections.S.index()];
                        IsoGridSquare isoGridSquare5 = isoGridSquare0.testPathFindAdjacent(null, -1, -1, 0)
                            ? null
                            : isoGridSquare0.nav[IsoDirections.NW.index()];
                        IsoGridSquare isoGridSquare6 = isoGridSquare0.testPathFindAdjacent(null, 1, -1, 0)
                            ? null
                            : isoGridSquare0.nav[IsoDirections.NE.index()];
                        IsoGridSquare isoGridSquare7 = isoGridSquare0.testPathFindAdjacent(null, -1, 1, 0)
                            ? null
                            : isoGridSquare0.nav[IsoDirections.SW.index()];
                        IsoGridSquare isoGridSquare8 = isoGridSquare0.testPathFindAdjacent(null, 1, 1, 0) ? null : isoGridSquare0.nav[IsoDirections.SE.index()];
                        if (isoGridSquare1 != isoGridSquare0.w
                            || isoGridSquare2 != isoGridSquare0.n
                            || isoGridSquare3 != isoGridSquare0.e
                            || isoGridSquare4 != isoGridSquare0.s
                            || isoGridSquare5 != isoGridSquare0.nw
                            || isoGridSquare6 != isoGridSquare0.ne
                            || isoGridSquare7 != isoGridSquare0.sw
                            || isoGridSquare8 != isoGridSquare0.se) {
                            this.paintSquare(int5, int4, (int)_float, 1.0F, 0.0F, 0.0F, 0.5F);
                        }
                    }

                    if (isoGridSquare0 != null
                        && (
                            isoGridSquare0.nav[IsoDirections.NW.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.NW.index()].nav[IsoDirections.SE.index()] != isoGridSquare0
                                || isoGridSquare0.nav[IsoDirections.NE.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.NE.index()].nav[IsoDirections.SW.index()] != isoGridSquare0
                                || isoGridSquare0.nav[IsoDirections.SW.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.SW.index()].nav[IsoDirections.NE.index()] != isoGridSquare0
                                || isoGridSquare0.nav[IsoDirections.SE.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.SE.index()].nav[IsoDirections.NW.index()] != isoGridSquare0
                                || isoGridSquare0.nav[IsoDirections.N.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.N.index()].nav[IsoDirections.S.index()] != isoGridSquare0
                                || isoGridSquare0.nav[IsoDirections.S.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.S.index()].nav[IsoDirections.N.index()] != isoGridSquare0
                                || isoGridSquare0.nav[IsoDirections.W.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.W.index()].nav[IsoDirections.E.index()] != isoGridSquare0
                                || isoGridSquare0.nav[IsoDirections.E.index()] != null
                                    && isoGridSquare0.nav[IsoDirections.E.index()].nav[IsoDirections.W.index()] != isoGridSquare0
                        )) {
                        int2 = (int)IsoUtils.XToScreenExact((float)int5, (float)(int4 + 1), _float, 0);
                        int3 = (int)IsoUtils.YToScreenExact((float)int5, (float)(int4 + 1), _float, 0);
                        SpriteRenderer.instance
                            .renderPoly(
                                (float)int2,
                                (float)int3,
                                (float)(int2 + 32),
                                (float)(int3 - 16),
                                (float)(int2 + 64),
                                (float)int3,
                                (float)(int2 + 32),
                                (float)(int3 + 16),
                                1.0F,
                                0.0F,
                                0.0F,
                                0.5F
                            );
                    }

                    if (this.EmptySquares.getValue() && isoGridSquare0.getObjects().isEmpty()) {
                        this.paintSquare(int5, int4, (int)_float, 1.0F, 1.0F, 0.0F, 0.5F);
                    }

                    if (isoGridSquare0.getRoom() != null
                        && isoGridSquare0.isFree(false)
                        && !zombie.VirtualZombieManager.instance.canSpawnAt(int5, int4, (int)_float)) {
                        this.paintSquare(int5, int4, (int)_float, 1.0F, 1.0F, 1.0F, 1.0F);
                    }

                    if (isoGridSquare0.roofHideBuilding != null) {
                        this.paintSquare(int5, int4, (int)_float, 0.0F, 0.0F, 1.0F, 0.25F);
                    }
                }
            }
        }

        if (IsoCamera.CamCharacter.getCurrentSquare() != null
            && Math.abs(this.gridX - (int)IsoCamera.CamCharacter.x) <= 1
            && Math.abs(this.gridY - (int)IsoCamera.CamCharacter.y) <= 1) {
            IsoGridSquare isoGridSquare9 = IsoWorld.instance.CurrentCell.getGridSquare(this.gridX, this.gridY, this.m_z);
            IsoObject isoObject = IsoCamera.CamCharacter.getCurrentSquare().testCollideSpecialObjects(isoGridSquare9);
            if (isoObject != null) {
                isoObject.getSprite().RenderGhostTileRed((int)isoObject.getX(), (int)isoObject.getY(), (int)isoObject.getZ());
            }
        }

        if (this.LineClearCollide.getValue()) {
            this.lineClearCached(
                IsoWorld.instance.CurrentCell,
                this.gridX,
                this.gridY,
                (int)_float,
                (int)IsoCamera.CamCharacter.getX(),
                (int)IsoCamera.CamCharacter.getY(),
                this.m_z,
                false
            );
        }

        if (this.NearestWallsOpt.getValue()) {
            NearestWalls.render(this.gridX, this.gridY, this.m_z);
        }

        if (this.VehicleStory.getValue()) {
            this.drawVehicleStory();
        }
    }

    private void drawZones() {
        ArrayList arrayList = IsoWorld.instance.MetaGrid.getZonesAt(this.gridX, this.gridY, this.m_z, new ArrayList());
        IsoMetaGrid.Zone zone0 = null;

        for (int int0 = 0; int0 < arrayList.size(); int0++) {
            IsoMetaGrid.Zone zone1 = (IsoMetaGrid.Zone)arrayList.get(int0);
            if (zone1.isPreferredZoneForSquare) {
                zone0 = zone1;
            }

            if (!zone1.isPolyline()) {
                if (!zone1.points.isEmpty()) {
                    for (byte byte0 = 0; byte0 < zone1.points.size(); byte0 += 2) {
                        int int1 = zone1.points.get(byte0);
                        int int2 = zone1.points.get(byte0 + 1);
                        int int3 = zone1.points.get((byte0 + 2) % zone1.points.size());
                        int int4 = zone1.points.get((byte0 + 3) % zone1.points.size());
                        this.DrawIsoLine((float)int1, (float)int2, (float)int3, (float)int4, 1.0F, 1.0F, 0.0F, 1.0F, 1);
                    }
                } else {
                    this.DrawIsoLine((float)zone1.x, (float)zone1.y, (float)(zone1.x + zone1.w), (float)zone1.y, 1.0F, 1.0F, 0.0F, 1.0F, 1);
                    this.DrawIsoLine(
                        (float)zone1.x, (float)(zone1.y + zone1.h), (float)(zone1.x + zone1.w), (float)(zone1.y + zone1.h), 1.0F, 1.0F, 0.0F, 1.0F, 1
                    );
                    this.DrawIsoLine((float)zone1.x, (float)zone1.y, (float)zone1.x, (float)(zone1.y + zone1.h), 1.0F, 1.0F, 0.0F, 1.0F, 1);
                    this.DrawIsoLine(
                        (float)(zone1.x + zone1.w), (float)zone1.y, (float)(zone1.x + zone1.w), (float)(zone1.y + zone1.h), 1.0F, 1.0F, 0.0F, 1.0F, 1
                    );
                }
            }
        }

        arrayList = IsoWorld.instance.MetaGrid.getZonesIntersecting(this.gridX - 1, this.gridY - 1, this.m_z, 3, 3, new ArrayList());
        PolygonalMap2.LiangBarsky liangBarsky = new PolygonalMap2.LiangBarsky();
        double[] _double = new double[2];
        IsoChunk isoChunk = IsoWorld.instance.CurrentCell.getChunkForGridSquare(this.gridX, this.gridY, this.m_z);

        for (int int5 = 0; int5 < arrayList.size(); int5++) {
            IsoMetaGrid.Zone zone2 = (IsoMetaGrid.Zone)arrayList.get(int5);
            if (zone2 != null && zone2.isPolyline() && !zone2.points.isEmpty()) {
                for (byte byte1 = 0; byte1 < zone2.points.size() - 2; byte1 += 2) {
                    int int6 = zone2.points.get(byte1);
                    int int7 = zone2.points.get(byte1 + 1);
                    int int8 = zone2.points.get(byte1 + 2);
                    int int9 = zone2.points.get(byte1 + 3);
                    this.DrawIsoLine((float)int6, (float)int7, (float)int8, (float)int9, 1.0F, 1.0F, 0.0F, 1.0F, 1);
                    float float0 = (float)(int8 - int6);
                    float float1 = (float)(int9 - int7);
                    if (isoChunk != null
                        && liangBarsky.lineRectIntersect(
                            (float)int6,
                            (float)int7,
                            float0,
                            float1,
                            (float)(isoChunk.wx * 10),
                            (float)(isoChunk.wy * 10),
                            (float)(isoChunk.wx * 10 + 10),
                            (float)(isoChunk.wy * 10 + 10),
                            _double
                        )) {
                        this.DrawIsoLine(
                            (float)int6 + (float)_double[0] * float0,
                            (float)int7 + (float)_double[0] * float1,
                            (float)int6 + (float)_double[1] * float0,
                            (float)int7 + (float)_double[1] * float1,
                            0.0F,
                            1.0F,
                            0.0F,
                            1.0F,
                            1
                        );
                    }
                }

                if (zone2.polylineOutlinePoints != null) {
                    float[] float2 = zone2.polylineOutlinePoints;

                    for (byte byte2 = 0; byte2 < float2.length; byte2 += 2) {
                        float float3 = float2[byte2];
                        float float4 = float2[byte2 + 1];
                        float float5 = float2[(byte2 + 2) % float2.length];
                        float float6 = float2[(byte2 + 3) % float2.length];
                        this.DrawIsoLine(float3, float4, float5, float6, 1.0F, 1.0F, 0.0F, 1.0F, 1);
                    }
                }
            }
        }

        IsoMetaGrid.VehicleZone vehicleZone = IsoWorld.instance.MetaGrid.getVehicleZoneAt(this.gridX, this.gridY, this.m_z);
        if (vehicleZone != null) {
            float float7 = 0.5F;
            float float8 = 1.0F;
            float float9 = 0.5F;
            float float10 = 1.0F;
            if (vehicleZone.isPolygon()) {
                for (byte byte3 = 0; byte3 < vehicleZone.points.size(); byte3 += 2) {
                    int int10 = vehicleZone.points.get(byte3);
                    int int11 = vehicleZone.points.get(byte3 + 1);
                    int int12 = vehicleZone.points.get((byte3 + 2) % vehicleZone.points.size());
                    int int13 = vehicleZone.points.get((byte3 + 3) % vehicleZone.points.size());
                    this.DrawIsoLine((float)int10, (float)int11, (float)int12, (float)int13, 1.0F, 1.0F, 0.0F, 1.0F, 1);
                }
            } else if (vehicleZone.isPolyline()) {
                for (byte byte4 = 0; byte4 < vehicleZone.points.size() - 2; byte4 += 2) {
                    int int14 = vehicleZone.points.get(byte4);
                    int int15 = vehicleZone.points.get(byte4 + 1);
                    int int16 = vehicleZone.points.get(byte4 + 2);
                    int int17 = vehicleZone.points.get(byte4 + 3);
                    this.DrawIsoLine((float)int14, (float)int15, (float)int16, (float)int17, 1.0F, 1.0F, 0.0F, 1.0F, 1);
                }

                if (vehicleZone.polylineOutlinePoints != null) {
                    float[] float11 = vehicleZone.polylineOutlinePoints;

                    for (byte byte5 = 0; byte5 < float11.length; byte5 += 2) {
                        float float12 = float11[byte5];
                        float float13 = float11[byte5 + 1];
                        float float14 = float11[(byte5 + 2) % float11.length];
                        float float15 = float11[(byte5 + 3) % float11.length];
                        this.DrawIsoLine(float12, float13, float14, float15, 1.0F, 1.0F, 0.0F, 1.0F, 1);
                    }
                }
            } else {
                this.DrawIsoLine(
                    (float)vehicleZone.x,
                    (float)vehicleZone.y,
                    (float)(vehicleZone.x + vehicleZone.w),
                    (float)vehicleZone.y,
                    float7,
                    float8,
                    float9,
                    float10,
                    1
                );
                this.DrawIsoLine(
                    (float)vehicleZone.x,
                    (float)(vehicleZone.y + vehicleZone.h),
                    (float)(vehicleZone.x + vehicleZone.w),
                    (float)(vehicleZone.y + vehicleZone.h),
                    float7,
                    float8,
                    float9,
                    float10,
                    1
                );
                this.DrawIsoLine(
                    (float)vehicleZone.x,
                    (float)vehicleZone.y,
                    (float)vehicleZone.x,
                    (float)(vehicleZone.y + vehicleZone.h),
                    float7,
                    float8,
                    float9,
                    float10,
                    1
                );
                this.DrawIsoLine(
                    (float)(vehicleZone.x + vehicleZone.w),
                    (float)vehicleZone.y,
                    (float)(vehicleZone.x + vehicleZone.w),
                    (float)(vehicleZone.y + vehicleZone.h),
                    float7,
                    float8,
                    float9,
                    float10,
                    1
                );
            }
        }

        if (this.RandomSquareInZone.getValue() && zone0 != null) {
            IsoGridSquare isoGridSquare = zone0.getRandomSquareInZone();
            if (isoGridSquare != null) {
                this.paintSquare(isoGridSquare.x, isoGridSquare.y, isoGridSquare.z, 0.0F, 1.0F, 0.0F, 0.5F);
            }
        }
    }

    private void drawVehicleStory() {
        ArrayList arrayList = IsoWorld.instance.MetaGrid.getZonesIntersecting(this.gridX - 1, this.gridY - 1, this.m_z, 3, 3, new ArrayList());
        if (!arrayList.isEmpty()) {
            IsoChunk isoChunk = IsoWorld.instance.CurrentCell.getChunkForGridSquare(this.gridX, this.gridY, this.m_z);
            if (isoChunk != null) {
                for (int int0 = 0; int0 < arrayList.size(); int0++) {
                    IsoMetaGrid.Zone zone = (IsoMetaGrid.Zone)arrayList.get(int0);
                    if ("Nav".equals(zone.type)) {
                        VehicleStorySpawner vehicleStorySpawner = VehicleStorySpawner.getInstance();
                        RandomizedVehicleStoryBase randomizedVehicleStoryBase = IsoWorld.instance.getRandomizedVehicleStoryByName(this.m_vehicleStory);
                        if (randomizedVehicleStoryBase != null
                            && randomizedVehicleStoryBase.isValid(zone, isoChunk, true)
                            && randomizedVehicleStoryBase.initVehicleStorySpawner(zone, isoChunk, true)) {
                            int int1 = randomizedVehicleStoryBase.getMinZoneWidth();
                            int int2 = randomizedVehicleStoryBase.getMinZoneHeight();
                            float[] float0 = new float[3];
                            if (randomizedVehicleStoryBase.getSpawnPoint(zone, isoChunk, float0)) {
                                float float1 = float0[0];
                                float float2 = float0[1];
                                float float3 = float0[2] + (float) (Math.PI / 2);
                                vehicleStorySpawner.spawn(float1, float2, 0.0F, float3, (var0, var1x) -> {
                                });
                                vehicleStorySpawner.render(float1, float2, 0.0F, (float)int1, (float)int2, float0[2]);
                            }
                        }
                    }
                }
            }
        }
    }

    private void DrawBehindStuff() {
        this.IsBehindStuff(IsoCamera.CamCharacter.getCurrentSquare());
    }

    private boolean IsBehindStuff(IsoGridSquare isoGridSquare) {
        for (int int0 = 1; int0 < 8 && isoGridSquare.getZ() + int0 < 8; int0++) {
            for (int int1 = -5; int1 <= 6; int1++) {
                for (int int2 = -5; int2 <= 6; int2++) {
                    if (int2 >= int1 - 5 && int2 <= int1 + 5) {
                        this.paintSquare(
                            isoGridSquare.getX() + int2 + int0 * 3,
                            isoGridSquare.getY() + int1 + int0 * 3,
                            isoGridSquare.getZ() + int0,
                            1.0F,
                            1.0F,
                            0.0F,
                            0.25F
                        );
                    }
                }
            }
        }

        return true;
    }

    private boolean IsBehindStuffRecY(int int0, int int1, int int2) {
        IsoGridSquare isoGridSquare = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, int2);
        if (int2 >= 15) {
            return false;
        } else {
            this.paintSquare(int0, int1, int2, 1.0F, 1.0F, 0.0F, 0.25F);
            return this.IsBehindStuffRecY(int0, int1 + 1, int2 + 1);
        }
    }

    private boolean IsBehindStuffRecXY(int int0, int int1, int int2, int int3) {
        IsoGridSquare isoGridSquare = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, int2);
        if (int2 >= 15) {
            return false;
        } else {
            this.paintSquare(int0, int1, int2, 1.0F, 1.0F, 0.0F, 0.25F);
            return this.IsBehindStuffRecXY(int0 + int3, int1 + int3, int2 + 1, int3);
        }
    }

    private boolean IsBehindStuffRecX(int int0, int int1, int int2) {
        IsoGridSquare isoGridSquare = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, int2);
        if (int2 >= 15) {
            return false;
        } else {
            this.paintSquare(int0, int1, int2, 1.0F, 1.0F, 0.0F, 0.25F);
            return this.IsBehindStuffRecX(int0 + 1, int1, int2 + 1);
        }
    }

    private void paintSquare(int int4, int int3, int int2, float float0, float float1, float float2, float float3) {
        int int0 = Core.TileScale;
        int int1 = (int)IsoUtils.XToScreenExact((float)int4, (float)(int3 + 1), (float)int2, 0);
        int int5 = (int)IsoUtils.YToScreenExact((float)int4, (float)(int3 + 1), (float)int2, 0);
        SpriteRenderer.instance
            .renderPoly(
                (float)int1,
                (float)int5,
                (float)(int1 + 32 * int0),
                (float)(int5 - 16 * int0),
                (float)(int1 + 64 * int0),
                (float)int5,
                (float)(int1 + 32 * int0),
                (float)(int5 + 16 * int0),
                float0,
                float1,
                float2,
                float3
            );
    }

    void drawModData() {
        int int0 = this.m_z;
        IsoGridSquare isoGridSquare = IsoWorld.instance.getCell().getGridSquare(this.gridX, this.gridY, int0);
        int int1 = Core.getInstance().getScreenWidth() - 250;
        int int2 = 10;
        int int3 = TextManager.instance.getFontFromEnum(this.FONT).getLineHeight();
        if (isoGridSquare != null && isoGridSquare.getModData() != null) {
            KahluaTable kahluaTable = isoGridSquare.getModData();
            int int4;
            this.DrawString(int1, int4 = int2 + int3, "MOD DATA x,y,z=" + isoGridSquare.getX() + "," + isoGridSquare.getY() + "," + isoGridSquare.getZ());
            KahluaTableIterator kahluaTableIterator0 = kahluaTable.iterator();

            while (kahluaTableIterator0.advance()) {
                this.DrawString(int1, int4 += int3, kahluaTableIterator0.getKey().toString() + " = " + kahluaTableIterator0.getValue().toString());
                if (kahluaTableIterator0.getValue() instanceof KahluaTable) {
                    KahluaTableIterator kahluaTableIterator1 = ((KahluaTable)kahluaTableIterator0.getValue()).iterator();

                    while (kahluaTableIterator1.advance()) {
                        this.DrawString(int1 + 8, int4 += int3, kahluaTableIterator1.getKey().toString() + " = " + kahluaTableIterator1.getValue().toString());
                    }
                }
            }

            int2 = int4 + int3;
        }

        if (isoGridSquare != null) {
            PropertyContainer propertyContainer = isoGridSquare.getProperties();
            ArrayList arrayList = propertyContainer.getPropertyNames();
            if (!arrayList.isEmpty()) {
                this.DrawString(int1, int2 += int3, "PROPERTIES x,y,z=" + isoGridSquare.getX() + "," + isoGridSquare.getY() + "," + isoGridSquare.getZ());
                Collections.sort(arrayList);

                for (String string : arrayList) {
                    this.DrawString(int1, int2 += int3, string + " = \"" + propertyContainer.Val(string) + "\"");
                }
            }

            for (IsoFlagType isoFlagType : IsoFlagType.values()) {
                if (propertyContainer.Is(isoFlagType)) {
                    this.DrawString(int1, int2 += int3, isoFlagType.toString());
                }
            }
        }

        if (isoGridSquare != null) {
            ErosionData.Square square = isoGridSquare.getErosionData();
            if (square != null) {
                int2 += int3;
                int int5;
                this.DrawString(int1, int5 = int2 + int3, "EROSION x,y,z=" + isoGridSquare.getX() + "," + isoGridSquare.getY() + "," + isoGridSquare.getZ());
                this.DrawString(int1, int2 = int5 + int3, "init=" + square.init);
                int int6;
                this.DrawString(int1, int6 = int2 + int3, "doNothing=" + square.doNothing);
                this.DrawString(int1, int2 = int6 + int3, "chunk.init=" + isoGridSquare.chunk.getErosionData().init);
            }
        }
    }

    void drawPlayerInfo() {
        int int0 = Core.getInstance().getScreenWidth() - 250;
        int int1 = Core.getInstance().getScreenHeight() / 2;
        int int2 = TextManager.instance.getFontFromEnum(this.FONT).getLineHeight();
        IsoGameCharacter isoGameCharacter = IsoCamera.CamCharacter;
        int int3;
        this.DrawString(int0, int3 = int1 + int2, "bored = " + isoGameCharacter.getBodyDamage().getBoredomLevel());
        this.DrawString(int0, int1 = int3 + int2, "endurance = " + isoGameCharacter.getStats().endurance);
        int int4;
        this.DrawString(int0, int4 = int1 + int2, "fatigue = " + isoGameCharacter.getStats().fatigue);
        this.DrawString(int0, int1 = int4 + int2, "hunger = " + isoGameCharacter.getStats().hunger);
        int int5;
        this.DrawString(int0, int5 = int1 + int2, "pain = " + isoGameCharacter.getStats().Pain);
        this.DrawString(int0, int1 = int5 + int2, "panic = " + isoGameCharacter.getStats().Panic);
        int int6;
        this.DrawString(int0, int6 = int1 + int2, "stress = " + isoGameCharacter.getStats().getStress());
        this.DrawString(int0, int1 = int6 + int2, "clothingTemp = " + ((IsoPlayer)isoGameCharacter).getPlayerClothingTemperature());
        int int7;
        this.DrawString(int0, int7 = int1 + int2, "temperature = " + isoGameCharacter.getTemperature());
        this.DrawString(int0, int1 = int7 + int2, "thirst = " + isoGameCharacter.getStats().thirst);
        int int8;
        this.DrawString(int0, int8 = int1 + int2, "foodPoison = " + isoGameCharacter.getBodyDamage().getFoodSicknessLevel());
        this.DrawString(int0, int1 = int8 + int2, "poison = " + isoGameCharacter.getBodyDamage().getPoisonLevel());
        int int9;
        this.DrawString(int0, int9 = int1 + int2, "unhappy = " + isoGameCharacter.getBodyDamage().getUnhappynessLevel());
        this.DrawString(int0, int1 = int9 + int2, "infected = " + isoGameCharacter.getBodyDamage().isInfected());
        int int10;
        this.DrawString(int0, int10 = int1 + int2, "InfectionLevel = " + isoGameCharacter.getBodyDamage().getInfectionLevel());
        this.DrawString(int0, int1 = int10 + int2, "FakeInfectionLevel = " + isoGameCharacter.getBodyDamage().getFakeInfectionLevel());
        int1 += int2;
        int int11;
        this.DrawString(int0, int11 = int1 + int2, "WORLD");
        this.DrawString(int0, int1 = int11 + int2, "globalTemperature = " + IsoWorld.instance.getGlobalTemperature());
    }

    public LosUtil.TestResults lineClearCached(IsoCell cell, int x1, int y1, int z1, int x0, int y0, int z0, boolean bIgnoreDoors) {
        int int0 = y1 - y0;
        int int1 = x1 - x0;
        int int2 = z1 - z0;
        int int3 = int1 + 100;
        int int4 = int0 + 100;
        int int5 = int2 + 16;
        if (int3 >= 0 && int4 >= 0 && int5 >= 0 && int3 < 200 && int4 < 200) {
            LosUtil.TestResults testResults = LosUtil.TestResults.Clear;
            byte _byte = 1;
            float float0 = 0.5F;
            float float1 = 0.5F;
            IsoGridSquare isoGridSquare0 = cell.getGridSquare(x0, y0, z0);
            if (Math.abs(int1) > Math.abs(int0) && Math.abs(int1) > Math.abs(int2)) {
                float float2 = (float)int0 / (float)int1;
                float float3 = (float)int2 / (float)int1;
                float0 += (float)y0;
                float1 += (float)z0;
                int1 = int1 < 0 ? -1 : 1;
                float2 *= (float)int1;
                float3 *= (float)int1;

                while (x0 != x1) {
                    x0 += int1;
                    float0 += float2;
                    float1 += float3;
                    IsoGridSquare isoGridSquare1 = cell.getGridSquare(x0, (int)float0, (int)float1);
                    this.paintSquare(x0, (int)float0, (int)float1, 1.0F, 1.0F, 1.0F, 0.5F);
                    if (isoGridSquare1 != null
                        && isoGridSquare0 != null
                        && isoGridSquare1.testVisionAdjacent(
                                isoGridSquare0.getX() - isoGridSquare1.getX(),
                                isoGridSquare0.getY() - isoGridSquare1.getY(),
                                isoGridSquare0.getZ() - isoGridSquare1.getZ(),
                                true,
                                bIgnoreDoors
                            )
                            == LosUtil.TestResults.Blocked) {
                        this.paintSquare(x0, (int)float0, (int)float1, 1.0F, 0.0F, 0.0F, 0.5F);
                        this.paintSquare(isoGridSquare0.getX(), isoGridSquare0.getY(), isoGridSquare0.getZ(), 1.0F, 0.0F, 0.0F, 0.5F);
                        _byte = 4;
                    }

                    isoGridSquare0 = isoGridSquare1;
                    int int6 = (int)float0;
                    int int7 = (int)float1;
                }
            } else if (Math.abs(int0) >= Math.abs(int1) && Math.abs(int0) > Math.abs(int2)) {
                float float4 = (float)int1 / (float)int0;
                float float5 = (float)int2 / (float)int0;
                float0 += (float)x0;
                float1 += (float)z0;
                int0 = int0 < 0 ? -1 : 1;
                float4 *= (float)int0;
                float5 *= (float)int0;

                while (y0 != y1) {
                    y0 += int0;
                    float0 += float4;
                    float1 += float5;
                    IsoGridSquare isoGridSquare2 = cell.getGridSquare((int)float0, y0, (int)float1);
                    this.paintSquare((int)float0, y0, (int)float1, 1.0F, 1.0F, 1.0F, 0.5F);
                    if (isoGridSquare2 != null
                        && isoGridSquare0 != null
                        && isoGridSquare2.testVisionAdjacent(
                                isoGridSquare0.getX() - isoGridSquare2.getX(),
                                isoGridSquare0.getY() - isoGridSquare2.getY(),
                                isoGridSquare0.getZ() - isoGridSquare2.getZ(),
                                true,
                                bIgnoreDoors
                            )
                            == LosUtil.TestResults.Blocked) {
                        this.paintSquare((int)float0, y0, (int)float1, 1.0F, 0.0F, 0.0F, 0.5F);
                        this.paintSquare(isoGridSquare0.getX(), isoGridSquare0.getY(), isoGridSquare0.getZ(), 1.0F, 0.0F, 0.0F, 0.5F);
                        _byte = 4;
                    }

                    isoGridSquare0 = isoGridSquare2;
                    int int8 = (int)float0;
                    int int9 = (int)float1;
                }
            } else {
                float float6 = (float)int1 / (float)int2;
                float float7 = (float)int0 / (float)int2;
                float0 += (float)x0;
                float1 += (float)y0;
                int2 = int2 < 0 ? -1 : 1;
                float6 *= (float)int2;
                float7 *= (float)int2;

                while (z0 != z1) {
                    z0 += int2;
                    float0 += float6;
                    float1 += float7;
                    IsoGridSquare isoGridSquare3 = cell.getGridSquare((int)float0, (int)float1, z0);
                    this.paintSquare((int)float0, (int)float1, z0, 1.0F, 1.0F, 1.0F, 0.5F);
                    if (isoGridSquare3 != null
                        && isoGridSquare0 != null
                        && isoGridSquare3.testVisionAdjacent(
                                isoGridSquare0.getX() - isoGridSquare3.getX(),
                                isoGridSquare0.getY() - isoGridSquare3.getY(),
                                isoGridSquare0.getZ() - isoGridSquare3.getZ(),
                                true,
                                bIgnoreDoors
                            )
                            == LosUtil.TestResults.Blocked) {
                        _byte = 4;
                    }

                    isoGridSquare0 = isoGridSquare3;
                    int int10 = (int)float0;
                    int int11 = (int)float1;
                }
            }

            if (_byte == 1) {
                return LosUtil.TestResults.Clear;
            } else if (_byte == 2) {
                return LosUtil.TestResults.ClearThroughOpenDoor;
            } else if (_byte == 3) {
                return LosUtil.TestResults.ClearThroughWindow;
            } else {
                return _byte == 4 ? LosUtil.TestResults.Blocked : LosUtil.TestResults.Blocked;
            }
        } else {
            return LosUtil.TestResults.Blocked;
        }
    }

    private void DrawString(int int3, int int2, String string) {
        int int0 = TextManager.instance.MeasureStringX(this.FONT, string);
        int int1 = TextManager.instance.getFontFromEnum(this.FONT).getLineHeight();
        SpriteRenderer.instance.renderi(null, int3 - 1, int2, int0 + 2, int1, 0.0F, 0.0F, 0.0F, 0.8F, null);
        TextManager.instance.DrawString(this.FONT, (double)int3, (double)int2, string, 1.0, 1.0, 1.0, 1.0);
    }

    public ConfigOption getOptionByName(String name) {
        for (int _int = 0; _int < this.options.size(); _int++) {
            ConfigOption configOption = (ConfigOption)this.options.get(_int);
            if (configOption.getName().equals(name)) {
                return configOption;
            }
        }

        return null;
    }

    public int getOptionCount() {
        return this.options.size();
    }

    public ConfigOption getOptionByIndex(int index) {
        return (ConfigOption)this.options.get(index);
    }

    public void setBoolean(String name, boolean value) {
        ConfigOption configOption = this.getOptionByName(name);
        if (configOption instanceof BooleanConfigOption) {
            ((BooleanConfigOption)configOption).setValue(value);
        }
    }

    public boolean getBoolean(String name) {
        ConfigOption configOption = this.getOptionByName(name);
        return configOption instanceof BooleanConfigOption ? ((BooleanConfigOption)configOption).getValue() : false;
    }

    public void save() {
        String string = zombie.ZomboidFileSystem.instance.getCacheDir() + File.separator + "debugChunkState-options.ini";
        ConfigFile configFile = new ConfigFile();
        configFile.write(string, 1, this.options);
    }

    public void load() {
        String string = zombie.ZomboidFileSystem.instance.getCacheDir() + File.separator + "debugChunkState-options.ini";
        ConfigFile configFile = new ConfigFile();
        if (configFile.read(string)) {
            for (int _int = 0; _int < configFile.getOptions().size(); _int++) {
                ConfigOption configOption0 = (ConfigOption)configFile.getOptions().get(_int);
                ConfigOption configOption1 = this.getOptionByName(configOption0.getName());
                if (configOption1 != null) {
                    configOption1.parse(configOption0.getValueAsString());
                }
            }
        }
    }

    public class BooleanDebugOption extends BooleanConfigOption {
        public BooleanDebugOption(String string, boolean _boolean) {
            super(string, _boolean);
            DebugChunkState.this.options.add(this);
        }
    }

    private class FloodFill {
        private IsoGridSquare start = null;
        private final int FLOOD_SIZE = 11;
        private BooleanGrid visited = new BooleanGrid(11, 11);
        private Stack<IsoGridSquare> stack = new Stack();
        private IsoBuilding building = null;
        private Mover mover = null;

        void calculate(Mover moverx, IsoGridSquare isoGridSquare) {
            this.start = isoGridSquare;
            this.mover = moverx;
            if (this.start.getRoom() != null) {
                this.building = this.start.getRoom().getBuilding();
            }

            boolean boolean0 = false;
            boolean boolean1 = false;
            if (this.push(this.start.getX(), this.start.getY())) {
                while ((isoGridSquare = this.pop()) != null) {
                    int int0 = isoGridSquare.getX();
                    int int1 = isoGridSquare.getY();

                    while (this.shouldVisit(int0, int1, int0, int1 - 1)) {
                        int1--;
                    }

                    boolean1 = false;
                    boolean0 = false;

                    do {
                        this.visited.setValue(this.gridX(int0), this.gridY(int1), true);
                        if (!boolean0 && this.shouldVisit(int0, int1, int0 - 1, int1)) {
                            if (!this.push(int0 - 1, int1)) {
                                return;
                            }

                            boolean0 = true;
                        } else if (boolean0 && !this.shouldVisit(int0, int1, int0 - 1, int1)) {
                            boolean0 = false;
                        } else if (boolean0 && !this.shouldVisit(int0 - 1, int1, int0 - 1, int1 - 1) && !this.push(int0 - 1, int1)) {
                            return;
                        }

                        if (!boolean1 && this.shouldVisit(int0, int1, int0 + 1, int1)) {
                            if (!this.push(int0 + 1, int1)) {
                                return;
                            }

                            boolean1 = true;
                        } else if (boolean1 && !this.shouldVisit(int0, int1, int0 + 1, int1)) {
                            boolean1 = false;
                        } else if (boolean1 && !this.shouldVisit(int0 + 1, int1, int0 + 1, int1 - 1) && !this.push(int0 + 1, int1)) {
                            return;
                        }

                        int1++;
                    } while (!this.shouldVisit(int0, int1 - 1, int0, int1));
                }
            }
        }

        boolean shouldVisit(int int2, int int3, int int0, int int1) {
            if (this.gridX(int0) < 11 && this.gridX(int0) >= 0) {
                if (this.gridY(int1) < 11 && this.gridY(int1) >= 0) {
                    if (this.visited.getValue(this.gridX(int0), this.gridY(int1))) {
                        return false;
                    } else {
                        IsoGridSquare isoGridSquare = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, this.start.getZ());
                        if (isoGridSquare == null) {
                            return false;
                        } else if (isoGridSquare.Has(IsoObjectType.stairsBN)
                            || isoGridSquare.Has(IsoObjectType.stairsMN)
                            || isoGridSquare.Has(IsoObjectType.stairsTN)) {
                            return false;
                        } else if (isoGridSquare.Has(IsoObjectType.stairsBW)
                            || isoGridSquare.Has(IsoObjectType.stairsMW)
                            || isoGridSquare.Has(IsoObjectType.stairsTW)) {
                            return false;
                        } else if (isoGridSquare.getRoom() != null && this.building == null) {
                            return false;
                        } else {
                            return isoGridSquare.getRoom() == null && this.building != null
                                ? false
                                : !IsoWorld.instance.CurrentCell.blocked(this.mover, int0, int1, this.start.getZ(), int2, int3, this.start.getZ());
                        }
                    }
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }

        boolean push(int int0, int int1) {
            IsoGridSquare isoGridSquare = IsoWorld.instance.CurrentCell.getGridSquare(int0, int1, this.start.getZ());
            this.stack.push(isoGridSquare);
            return true;
        }

        IsoGridSquare pop() {
            return this.stack.isEmpty() ? null : (IsoGridSquare)this.stack.pop();
        }

        int gridX(int _int) {
            return _int - (this.start.getX() - 5);
        }

        int gridY(int _int) {
            return _int - (this.start.getY() - 5);
        }

        int gridX(IsoGridSquare isoGridSquare) {
            return isoGridSquare.getX() - (this.start.getX() - 5);
        }

        int gridY(IsoGridSquare isoGridSquare) {
            return isoGridSquare.getY() - (this.start.getY() - 5);
        }

        void draw() {
            int int0 = this.start.getX() - 5;
            int int1 = this.start.getY() - 5;

            for (int int2 = 0; int2 < 11; int2++) {
                for (int int3 = 0; int3 < 11; int3++) {
                    if (this.visited.getValue(int3, int2)) {
                        int int4 = (int)IsoUtils.XToScreenExact((float)(int0 + int3), (float)(int1 + int2 + 1), (float)this.start.getZ(), 0);
                        int int5 = (int)IsoUtils.YToScreenExact((float)(int0 + int3), (float)(int1 + int2 + 1), (float)this.start.getZ(), 0);
                        SpriteRenderer.instance
                            .renderPoly(
                                (float)int4,
                                (float)int5,
                                (float)(int4 + 32),
                                (float)(int5 - 16),
                                (float)(int4 + 64),
                                (float)int5,
                                (float)(int4 + 32),
                                (float)(int5 + 16),
                                1.0F,
                                1.0F,
                                0.0F,
                                0.5F
                            );
                    }
                }
            }
        }
    }
}
